package com.school.repair.service;

import com.school.repair.dao.RepairManDao;
import com.school.repair.entity.BaoXiuDan;
import com.school.repair.entity.BaoXiuMan;
import com.school.repair.entity.RepairMan;
import com.school.repair.entity.Todo;
import com.school.repair.util.Page;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
@Service
public class RepairManService {

    @Resource
    RepairManDao repairManDao;

    public Page<RepairMan> repairManPage(int pageNo, int pageSize, String name, String goodat) {
            List<RepairMan> list = repairManDao.repairManPage(pageNo, pageSize, name, goodat);
            int total = repairManDao.total(name, goodat);
            return new Page<RepairMan>(total, list, pageNo);
    }


    public RepairMan login(String name, String yzm) {
        return repairManDao.login(name,yzm);
    }

    public int add(RepairMan repairMan) {
        return repairManDao.add(repairMan);
    }

    public int VerifyName(String name,long id) {
        return repairManDao.VerifyName(name,id);
    }

    public int update(RepairMan repairMan) {
        return repairManDao.adminUpdateRepairMan(repairMan);
    }

    public Page<BaoXiuDan> repairmanBaoxiudans(int pageNo, int pageSize, long repairmanId) {
        List<BaoXiuDan> list= repairManDao.repairmanBaoxiudans(pageNo,pageSize,repairmanId);
        int total = repairManDao.searchTotal(repairmanId);
        return new Page<BaoXiuDan>(total,list,pageNo);
    }

    public Page<Todo> todosBy(long id,int pageNo,int pageSize) {
        List<Todo> list= repairManDao.todosBy(pageNo,pageSize,id);
        int total=repairManDao.todoTotalBy(id);
        return new Page<Todo>(total,list,pageNo);
    }
}
